여자친구의 싸이월드를 블로그로 퍼오기 위해서 만든 class입니다.
PEAR의 HTTP_Request 만 설치되어 있으면 사용하실 수 있습니다.
<?php require_once 'HTTP/Request.php';
/** * CYWORLD service proxy * * http://fguy.com * * @author fguy <flowerguy@gmail.com> * @copyright copy left. no rights reserved. */ class Cyworld { const DATE_FORMAT_ISO8601 = '%Y%m%dT%H:%M:%S'; const GUESTBOOK_ITEM_COUNT = 5; /** * CYWORLD unique id * @var string */ private $_tid;
/** * HTTP Cookie collection * @var array */ private $_cookies;
/** * HTTP_Request instance * @var HTTP_Request */ private $_request;
/** * inside body read * @var string */ private $_insideBody; private $_photoBody;
private $_photoPage = 1; private $_photoFolderId = 0; private $_guestbookYear; private $_guestbookBody; private $_guestbookPage = 1; private $_movieBody; private $_moviePage = 1; private $_movieFolderId = 0; private $_bbsBody; private $_bbsPage = 1; private $_bbsFolderId = 0;
/** * 생성자 * * @param string $id tid or id */ public function __construct($id = null) { if($id) { if (is_numeric($id)) { $this->_tid = $id; } else { $this->_tid = $this->_getTidById($id); } } }
/** * ID로 tid 를 찾는다. * * @param string $id id * @return string */ private function _getTidById($id) { $request = new HTTP_Request(); $request->setURL('http://cyworld.com/' . $id);
if (!PEAR :: isError($request->sendRequest())) { $body = $request->getResponseBody(); $matches = array (); preg_match('/pims\/main\/domain2\.asp\?tid=([0-9]+)/', $body, $matches); return $matches[1]; } throw new Exception('failed to retrive tid by id'); } /** * 세션 정보로 tid를 찾아서 set */ private function _getTid() { $request = new HTTP_Request(); $request->setURL('http://www.cyworld.com/main2/mycyworld/mycy_info_personal.asp');
$request = $this->_applyCookie($request);
if (!PEAR :: isError($request->sendRequest())) { $body = $request->getResponseBody(); $matches = array (); preg_match('/javascript:person_info2\(\'([0-9]+)\'\);/', $body, $matches); if(!$matches[1]) { throw new Exception('can not read tid from personal info page'); } return $matches[1]; } throw new Exception('failed to retrive tid by session info'); }
/** * 로그인 한다. * * @param string $email email address * @param string $password cyworld login password */ public function login($email, $password) { $request = new HTTP_Request(); // get cookie by login $request->setURL('http://cyxso.cyworld.com/login.jsp'); $request->setMethod(HTTP_REQUEST_METHOD_POST); $request->addHeader('Referer', 'http://minihp.cyworld.com/pims/main/pims_login_popup.asp?channel=minihp&dest=http%3A//minihp.cyworld.com/pims/main/pims_main.asp%3Ftid%3D' . $this->_tid . '&sid=' . $this->_tid . '&direction=NaN'); $request->addPostData('email', $email); $request->addPostData('passwd', $password); $request->addPostData('dest', 'http://minihp.cyworld.com/pims/main/pims_main.asp?tid=' . $this->_tid); $request->addPostData('jcode', ''); $request->addPostData('pop', 'ok'); $request->addPostData('domain', ''); $request->addPostData('return_domain', 'minihp.cyworld.com');
if (!PEAR :: isError($request->sendRequest())) { $this->_cookies = $request->getResponseCookies(); $isValid = false; foreach($this->_cookies as $item) { if($item['name'] == 'cookieinfouser') { $isValid = true; } } if(!$isValid) { throw new Exception('login failed. try another email or password'); } } else { throw new Exception('login failed. try another email or password'); } // retrive tid if it does not set if($isValid && !$this->_tid) { $this->_tid = $this->_getTid(); } $request->clearPostData(); } private function _applyCookie($request) { if(is_array($this->_cookies)) { // set cookie foreach ($this->_cookies as $cookie) { $request->addCookie($cookie['name'], $cookie['value']); } } return $request; } private function _getBody($url) { $request = new HTTP_Request(); $request->setURL($url);
$request = $this->_applyCookie($request); $response = $request->sendRequest(); if (!PEAR :: isError($response)) { return preg_replace("/\s\s+/", " ", $request->getResponseBody()); } throw new Exception('can not read body : ' . $url); }
private function _getInsideBody() { if (!$this->_insideBody) { $this->_insideBody = $this->_getBody('http://www.cyworld.com/pims/main/main_inside.asp?choco=ok&dpop=&domain=&tid=' . $this->_tid . '&urlstr=&send_seq=&productseq='); } return $this->_insideBody; }
private function _parseBoardComments($body, $year = null) { $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<a href=\'?"?javascript:PZPopup\(\'?[0-9]+\'?\)\'?"?>(.*?)<\/a>'; // name $patterns[] = ' : (.*?)<font'; // content $patterns[] = ' class=\'?"?verdana\'?"?>\s?\((.*?)\)<\/font>'; // date preg_match_all('/' . implode('.*?', $patterns) . '/', $body, $matches); foreach($matches[0] as $i => $item) { $result[$i]['name'] = $matches[1][$i]; $result[$i]['content'] = $matches[2][$i]; if($year) { $date = $year . '.' . $matches[3][$i]; } else { $date = $matches[3][$i]; } $result[$i]['date'] = $this->_convertDateToISO8601($date); } return $result; } private function _parseCategoryList($url) { $request = new HTTP_Request(); $request->setURL($url);
$request = $this->_applyCookie($request); $response = $request->sendRequest(); if (!PEAR :: isError($response)) { $body = $request->getResponseBody(); $albums = array (); preg_match_all('/<span id=\'foldernm([0-9]+)\'>(.*?)<\/span>/', $body, $albums);
$result = array (); foreach ($albums[0] as $i => $item) { $result[$albums[1][$i]] = strip_tags($albums[2][$i]); } return $result; } throw new Exception('can not read body of category page : ' . $url); } private function _convertAccess($access) { $access = trim($access); if(strlen($access) < 8) { return 'private'; } if(substr(md5($access), 0 , 1) == 'a') { return 'public'; } return 'protected'; } private function _convertDateToISO8601($string) { $time = strtotime(str_replace(".","/", $string)); return strftime(self :: DATE_FORMAT_ISO8601,$time); }
/** * 최근 업데이트 내역을 가져온다. * * @return array */ public function getUpdateList() { if ($body = $this->_getInsideBody()) { $updates = array ();
preg_match_all("/<img src='http:\/\/c1img.cyworld.co.kr\/img\/icon\/rec_01.gif' width='7' height='7'><a href=(.*?)>(.*?)<\/a>/", $body, $updates);
$result = array ();
foreach ($updates[0] as $i => $item) { $result[$i]['link'] = 'http://minihp.cyworld.com' . $this->_getUpdateLink($updates[1][$i]); $result[$i]['title'] = $updates[2][$i]; }
return $result; } throw new Exception('can not read body of cyworld main inside'); }
private function _getUpdateLink($item) { $tmp = explode(',', str_replace(array ( 'javascript:pimslink(', "'", ')' ), '', $item));
switch ($tmp[1]) { case 'myro' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'myin' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'mana' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'myro_edit' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'prof' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'stor_list' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'stor_manage' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; case 'stor_manage' : return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&intpage=' . $tmp[2] . '&mseq=' . $tmp[3]; default : if (!$tmp[2] && !$tmp[3]) { return '/pims/main/' . $tmp[0] . '.asp?urlstr=' . $tmp[1] . '&tid=' . $this->_tid . '&seq=' . $tmp[2] . '&board_no=' . $tmp[2] . '&item_seq=' . $tmp[3] . '&item_seq_main=' . $tmp[3]; } return '/pims/main/pims_updatechk_ok.asp?urlstr=' . $tmp[1] . '&board_type=' . $tmp[0] . '&board_no=' . $tmp[2] . '&item_seq=' . $tmp[3] . '&tid=' . $this->_tid . ''; } }
/** * 스토리룸의 iframe 내용을 가져온다. * * @return string */ public function getStoryRoom() { if ($body = $this->_getInsideBody()) { $storyroom = array (); preg_match("/storyroom_iframe.innerHTML = '(.*?)'/", $body, $storyroom); return str_replace('src="', 'src="http://minihp.cyworld.com', $storyroom[1]); } throw new Exception('can not read body of cyworld main inside'); }
/** *1촌평 목록을 가져온다. * * @return array */ public function getOneDegreeNoteList() { $body = $this->_getBody('http://www.cyworld.com/pims/main/main_inside_onedegnote.asp?tid=' . $this->_tid); $onedegnotes = array (); preg_match_all('/<a href="javascript:OneMemoPop_history\(\'[0-9]+\'\)" class="chon"><span style=\'background-color: # ; color:# ; text-decoration: none; \'>(.*?)<\/span><\/a> \((.*?<\/a>)\)/', $body, $onedegnotes);
$result = array (); $matches = array ();
foreach ($onedegnotes[0] as $i => $item) { $result[$i]['title'] = $onedegnotes[1][$i]; $result[$i]['author'] = strip_tags($onedegnotes[2][$i]); preg_match('/PZPopup2\(\'([0-9]+)\'\)/', $onedegnotes[2][$i], $matches); $result[$i]['link'] = 'http://minihp.cyworld.com/pims/main/pims_main.asp?tid=' . $matches[1]; } return $result; } private function _getPhotoBody($folderId, $page = 1) { if($this->_photoFolderId != $folderId || $this->_photoPage != $page || !$this->_photoBody) { $this->_photoFolderId = $folderId; $this->_photoPage = $page; $this->_photoBody = $this->_getBody('http://www.cyworld.com/pims/board/image/imgbrd_list.asp?tid=' . $this->_tid . '&board_no='. $folderId . '&search_content=&search_type=&search_keyword=&cpage=' . $page . '&AllCnt=0&board_nm='); } return $this->_photoBody; } /** * 폴더 내 사진의 페이지 수를 가져온다. * * @param int $folderId folder id (0 이면 전체) * @return int * */ public function getPhotoPageCount($folderId = 0) { $firstCount = count($this->getPhotoList($folderId, 1)); if($firstCount == 0) { return 0; } return ceil($this->getPhotoCount($folderId) / $firstCount); } /** * 폴더 내 전체 사진의 수를 가져온다. * * @param int $folderId folder id (0 이면 전체) * @return int */ public function getPhotoCount($folderId = 0) { $matches = array(); preg_match('/<font class="num style2">\(([0-9]+)\)<\/font>/', $this->_getPhotoBody($folderId), $matches); return $matches[1]; } /** * 사진 폴더의 목록을 가져온다. * * @return array */ public function getPhotoFolderList() { return $this->_parseCategoryList('http://www.cyworld.com/pims/main/pims_photo.asp?urlstr=phot&tid=' . $this->_tid . '&seq=&board_no=&item_seq=&item_seq_main='); }
/** * 사진 목록을 가져온다. * * @param int $folderId folder id (0이면 전체) * @param int $page 페이지 * * @return array */ public function getPhotoList($folderId = 0, $page = 1) { $body = $this->_getPhotoBody($folderId, $page); $matches = array(); $patterns = array(); $patterns[] = '<td align="center" class="gray_b" width="352">(.*?)<\/td>'; // title $patterns[] = '<a href="javascript:PZPopup\([0-9]+\)">(.*?)<\/a>'; //writer $patterns[] = '<font class="num" color="#333333"> (.*?)<\/font>'; // date $patterns[] = '(<img src="(.*?)".*? id="photo_[0-9]+">|<script type="text\/javascript"> obj_swfphoto\(\'(.*?)\')'; // photo or flash $patterns[] = '<span id="brd_content_[0-9]+" name="brd_content_[0-9]+">(.*?)<\/span>'; // content $patterns[] = '<span id="bopenText[0-9]+">(.*?)<\/span>'; // access $patterns[] = '<table.*?action="imgbrd_replyok\.asp".*?<td>(.*?) <\/td> <\/tr> <\/table>'; // comments preg_match_all('/' . implode('.*?', $patterns) . '/', $body, $matches); foreach($matches[0] as $i => $item) { $result[$i]['title'] = $matches[1][$i]; $result[$i]['writer'] = $matches[2][$i]; $result[$i]['date'] = $this->_convertDateToISO8601($matches[3][$i]); $result[$i]['img'] = $matches[5][$i]; $result[$i]['swf'] = $matches[6][$i]; $result[$i]['content'] = $matches[7][$i]; $result[$i]['access'] = $this->_convertAccess($matches[8][$i]); $result[$i]['comments'] = $this->_parseBoardComments($matches[9][$i], substr($result[$i]['date'], 0, 4)); } return $result; } private function _getGuestbookBody($year = null, $page = 1) { if(!$year) { $year = date('Y'); } if ($this->_guestbookYear != $year || $this->_guestbookPage != $page || !$this->_guestbookBody) { $this->_guestbookYear = $year; $this->_guestbookPage = $page; $this->_guestbookBody = $this->_getBody('http://www.cyworld.com/pims/visitbook/visitbook_list.asp?intpage=' . $page . '&tid=' . $this->_tid . '&list_type=1&search_year=' . $year . '&search_type=0&search_keyword='); } return $this->_guestbookBody; } /** * 방명록에 등록된 년도별 전체 글 수를 가져온다. * * @param int $year 년도 * @return int 전체 글 수 */ public function getGuestbookCount($year = null) { $body = $this->_getGuestbookBody($year, 1); $matches = array(); preg_match('/class="num">([0-9]+)<\/span>/', $body, $matches); return $matches[1]; } /** * 방명록에 등록된 글의 전체 페이지 수를 가져온다. * * @param int $year 년도 * @return int */ public function getGuestbookPageCount($year = null) { return ceil($this->getGuestbookCount($year) / self :: GUESTBOOK_ITEM_COUNT); } /** * 방명록 글 목록을 페이지별로 가져온다. * * @param int $page 페이지 * @param int $year 년도 * * @return array */ public function getGuestbookList($year = null, $page = 1) { $body = $this->_getGuestbookBody($year, $page); $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<a href="javascript:PZPopup\(\'[0-9]+\'\)">(.*?)<\/a>'; //writer //<font color="#666666" class="num" > ( 2007.08.25 00:20 )</font> $patterns[] = '<font color="#666666" class="num" > \( (.*?) \)<\/font>'; // date $patterns[] = '<td id="secret_cv[0-9]+" align="left" .*?>(.*?)<\/td>'; // content $patterns[] = '<table id="reply_box_area_[0-9]+".*?<td align="left" class="gray">(.*?)<\/td>'; // comments preg_match_all('/' . implode('.*?', $patterns) . '/', $body, $matches); foreach($matches[0] as $i => $item) { $result[$i]['writer'] = $matches[1][$i]; $result[$i]['date'] = $this->_convertDateToISO8601($matches[2][$i]); $result[$i]['content'] = str_replace('<img src="','',$matches[3][$i">http://c1img.cyworld.co.kr/img/pwin/visit_lock1.gif">','',$matches[3][$i]); $result[$i]['access'] = strpos($matches[3][$i],'<img src="'">http://c1img.cyworld.co.kr/img/pwin/visit_lock1.gif">') > 0 ? 'private' : 'public'; $result[$i]['comments'] = $this->_parseGuestbookComments($matches[4][$i]); } return $result; } private function _parseGuestbookComments($body) { $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<a href="javascript:PZPopup\(\'[0-9]+\'\)">(.*?)<\/a> '; // name $patterns[] = '<span id=\'org_rep_msg[0-9]+\'>(.*?)<\/span>'; // content $patterns[] = '<font color="#999999" class="num"> \((.*?)\)<\/font>'; // date preg_match_all('/' . implode('.*?', $patterns) . '/', $body, $matches); foreach($matches[0] as $i => $item) { $result[$i]['name'] = $matches[1][$i]; $result[$i]['content'] = $matches[2][$i]; $result[$i]['date'] = $this->_convertDateToISO8601($matches[3][$i]); } return $result; } /** * 동영상 폴더 목록을 가져온다. * * @return array */ public function getMovieFolderList() { return $this->_parseCategoryList('http://minihp.cyworld.com/pims/main/pims_video.asp?tid=' . $this->_tid . '&urlstr=video'); } /** * 폴더 내 동영상 갯수를 가져온다. * * @param int $folderId folder id (0이면 전체) * * @return int */ public function getMovieCount($folderId = 0) { $matches = array(); preg_match('/<font color="#FF3300">\(([0-9]+)\)<\/font>/', $this->_getMovieBody($folderId), $matches); return $matches[1]; } /** * 폴더 내 동영상의 페이지 수를 가져온다. * * @param int $folderId folder id (0 이면 전체) * @return int * */ public function getMoviePageCount($folderId = 0) { $firstCount = count($this->getMovieList($folderId, 1)); if($firstCount == 0) { return 0; } return ceil($this->getMovieCount($folderId) / $firstCount); } private function _getMovieBody($folderId = 0, $page = 1) { if($this->_movieFolderId != $folderId || $this->_moviePage != $page || !$this->_movieBody) { $this->_movieFolderId = $folderId; $this->_moviePage = $page; $this->_movieBody = $this->_getBody('http://minihp.video.cyworld.com/pims/board/video/videobrd_list.asp?tid=' . $this->_tid . '&list_type=0&board_no=' . $folderId . '&search_type=&search_keyword=&cpage=' . $page . '&last_item_seq=&AllCnt=&board_nm='); } return $this->_movieBody; } /** * 동영상 목록을 페이지별로 가져온다. * * @param int $folderId folder id (0이면 전체) * @param int $page 페이지 * * @return array */ public function getMovieList($folderId = 0, $page = 1) { $body = $this->_getMovieBody($folderId, $page); $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<a href="javascript\:view_detail\([0-9]+, ([0-9]+), ([0-9]+)\)"><img src="(.*?)" border="0" width="100" height="75" name=img_[0-9]+><\/a>'; //listid, boardId, thumbnail $patterns[] = '<strong><a href="javascript\:view_detail\([0-9]+, [0-9]+, [0-9]+\)">(.*?)<\/a><\/strong>'; preg_match_all('/' . implode('.*?', $patterns) . '/', $body, $matches); foreach($matches[0] as $i => $item) { $result[$i] = $this->_parseMovieDetail($matches[1][$i], $matches[2][$i], $page); $result[$i]['thumbnail'] = $matches[3][$i]; $result[$i]['title'] = $matches[4][$i]; } return $result; } private function _parseMovieDetail($itemSeq, $boardNo, $page) { $body = $this->_getBody('http://minihp.video.cyworld.com/pims/board/video/videobrd_view.asp?tid=' . $this->_tid . '&item_seq=' . $itemSeq . '&board_no=' . $boardNo . '&cpage=' . $page . '&list_type=0'); $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<font class="num" color="#333333">(.*?)<\/font>'; //date $patterns[] = 'new SWFObject\("\.\/(.*?)"'; // swf path $patterns[] = 'so\.addVariable\("v_key", "(.*?)"\)'; // swf v_key $patterns[] = 'so\.addVariable\("mov_id", "([0-9]+)"\)'; // swf mov_id $patterns[] = 'so\.addVariable\("c_id", "(.*?)"\)'; // swf c_id $patterns[] = '<table width="400" border="0" cellspacing="0" cellpadding="10">.*?<td style="width\:380px;.*?">(.*?)<\/td>'; // content $patterns[] = '<font color="#999999">.*? \:(.*?)<\/font>'; // access $patterns[] = 'videobrd_replyok.asp" (.*?) <\/td> <\/tr> <\/table>'; // comment block preg_match('/' . implode('.*?', $patterns) . '/', $body, $matches); $result['date'] = $this->_convertDateToISO8601($matches[1]); $result['swf'] = 'http://minihp.video.cyworld.com/pims/board/video/' . $matches[2] . '?v_key=' . $matches[3] . '&mov_id=' . $matches[4] . '&c_id=' . $matches[5]; $result['content'] = $matches[6]; $result['access'] = $this->_convertAccess($matches[7]); $result['comments'] = $this->_parseBoardComments($matches[8],substr($result['date'], 0, 4)); return $result; } /** * 게시판 폴더 목록을 가져온다. * * @return array */ public function getBbsFolderList() { return $this->_parseCategoryList('http://minihp.cyworld.com/pims/main/bbs_main.asp?tid=' . $this->_tid .'&urlstr=visi'); } /** * 게시판에 등록된 글의 수를 가져온다. * * @param int $folderId folder id (0이면 전체) * * @return int */ public function getBbsCount($folderId = 0) { $matches = array(); preg_match('/<font class="num style2">\(([0-9]+)\)<\/font>/', $this->_getBbsBody($folderId), $matches); return $matches[1]; } /** * 폴더 내 게시판의 페이지 수를 가져온다. * * @param int $folderId folder id (0 이면 전체) * @return int * */ public function getBbsPageCount($folderId = 0) { $firstCount = count($this->getBbsList($folderId, 1)); if($firstCount == 0) { return 0; } return ceil($this->getBbsCount($folderId) / $firstCount); } private function _getBbsBody($folderId = 0, $page = 1) { if($this->_bbsFolderId != $folderId || $this->_bbsPage != $page ||!$this->_bbsBody) { $this->_bbsFolderId = $folderId; $this->_bbsPage = $page; $this->_bbsBody = $this->_getBody('http://minihp.cyworld.com/pims/board/general/board_list.asp?domain=&tid=' . $this->_tid . '&board_no=' . $folderId . '&list_type=&urlstr=visi&bd_name='); } return $this->_bbsBody; } /** * 게시판 목록을 가져온다. * * @param int $folderId folder id (0이면 전체) * @param int $page 페이지 * * @return array */ public function getBbsList($folderId = 0, $page = 1) { $body = $this->_getBbsBody($folderId, $page); $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<a href="(board_view\.asp.*?)" > (.*?) <\/a>'; // detail path, title preg_match_all('/' . implode('.*?', $patterns) . '/', $body, $matches); foreach($matches[0] as $i => $item) { $result[$i] = $this->_parseBbsDetail($matches[1][$i], $page); $result[$i]['title'] = strip_tags($matches[2][$i]); } return $result; } private function _parseBbsDetail($path, $page) { $body = $this->_getBody('http://minihp.cyworld.com/pims/board/general/' . $path); $result = array(); $matches = array(); $patterns = array(); $patterns[] = '<font class="num" color="#333333">(.*?)<\/font>'; //date $patterns[] = '<span class="f11">.*?(<a href=\'(.*?)\' target=_new>(.*?)<\/a>)? <\/td>'; // attachment $patterns[] = '<td class=\'black_130\'>(.*?)<\/td>'; // content $patterns[] = '<span id="bopenText">(.*?)<\/span>'; //access $patterns[] = '_replyok.asp" (.*?) <\/td> <\/tr> <\/table>'; // comment block preg_match('/' . implode('.*?', $patterns) . '/', $body, $matches); $result['date'] = $this->_convertDateToISO8601($matches[1]); $result['filepath'] = $matches[3]; $result['filename'] = $matches[4]; $result['content'] = $matches[5]; $result['access'] = $this->_convertAccess($matches[6]); $result['comments'] = $this->_parseBoardComments($matches[7],substr($result['date'], 0, 4)); return $result; } /** * 인증이 필요한 파일을 가져온다. * * @param string $url 파일의 url * * @return string 파일의 binary 내용 */ public function getFile($url) { $request = new HTTP_Request(); $request->setURL($url); $request->addHeader('Referer', $url);
$request = $this->_applyCookie($request); $response = $request->sendRequest(); return $request->getResponseBody(); } } ?>
출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=56089&sca=&sfl=wr_subject%7C%7Cwr_content&stx=php5&sop=and |